import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import Moment from "moment";
import "./assets/js/axios";

import {
  Message,
  Form,
  FormItem,
  Input,
  Button,
  Icon,
  Checkbox,
  CheckboxGroup,
  Spin,
  TimePicker,
  Select,
  Option,
} from "view-design";
import "view-design/dist/styles/iview.css";

Vue.component("Form", Form);
Vue.component("FormItem", FormItem);
Vue.component("Input", Input);
Vue.component("Button", Button);
Vue.component("Icon", Icon);
Vue.component("Checkbox", Checkbox);
Vue.component("CheckboxGroup", CheckboxGroup);
Vue.component("TimePicker", TimePicker);
Vue.component("Select", Select);
Vue.component("Option", Option);

Vue.prototype.$Message = Message;
Vue.prototype.$Spin = Spin;

// 这个接口地址是模拟接口，需要启动这个项目https://gitee.com/tianyu0-0/node-mock
axios.defaults.baseURL = "http://192.168.37.68:9000/ele-calendar"; // 默认请求路径
axios.defaults.headers.common["Authorization"] = sessionStorage.getItem(
  "token"
); // 设置token
Vue.config.productionTip = false;

let $Vue = new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");

// 定义全局时间戳过滤器
Vue.filter("formatDate", (value = new Date(), str) => {
  Moment.locale("zh-CN");
  return Moment(value).format(str);
});

export default $Vue;
